{% extends 'generic/object.html' %}
{% load helpers %}
{% load plugins %}

{% block breadcrumbs %}
  <li><a href="{% url 'dcim:location_list' %}">Locations</a></li>
  {% for location in object.get_ancestors %}
    <li><a href="{{ location.get_absolute_url }}">{{ location }}</a></li>
  {% endfor %}
  <li>{{ object }}</li>
{% endblock %}

{% block content %}
<div class="row">
	<div class="col-md-6">
    <div class="panel panel-default">
      <div class="panel-heading">
        <strong>Location</strong>
      </div>
      <table class="table table-hover panel-body attr-table">
        <tr>
          <td>Name</td>
          <td>{{ object.name }}</td>
        </tr>
        <tr>
          <td>Description</td>
          <td>{{ object.description|placeholder }}</td>
        </tr>
        <tr>
          <td>Site</td>
          <td><a href="{{ object.site.get_absolute_url }}">{{ object.site }}</a></td>
        </tr>
        <tr>
          <td>Parent</td>
          <td>
            {% if object.parent %}
              <a href="{{ object.parent.get_absolute_url }}">{{ object.parent }}</a>
            {% else %}
              <span class="text-muted">&mdash;</span>
            {% endif %}
          </td>
        </tr>
        <tr>
          <td>Racks</td>
          <td>
            <a href="{% url 'dcim:rack_list' %}?location_id={{ object.pk }}">{{ rack_count }}</a>
          </td>
        </tr>
        <tr>
          <td>Devices</td>
          <td>
            <a href="{% url 'dcim:device_list' %}?location_id={{ object.pk }}">{{ device_count }}</a>
          </td>
        </tr>
      </table>
    </div>
    {% plugin_left_page object %}
  </div>
	<div class="col-md-6">
    {% include 'inc/custom_fields_panel.html' %}
    <div class="panel panel-default">
        <div class="panel-heading">
            <strong>Images</strong>
        </div>
        {% include 'inc/image_attachments.html' with images=object.images.all %}
        {% if perms.extras.add_imageattachment %}
            <div class="panel-footer text-right noprint">
                <a href="{% url 'dcim:location_add_image' object_id=object.pk %}" class="btn btn-primary btn-xs">
                    <span class="mdi mdi-plus-thick" aria-hidden="true"></span>
                    Attach an image
                </a>
            </div>
        {% endif %}
    </div>
    {% plugin_right_page object %}
	</div>
</div>
<div class="row">
	<div class="col-md-12">
    <div class="panel panel-default">
      <div class="panel-heading">
        <strong>Locations</strong>
      </div>
      {% include 'inc/table.html' with table=child_locations_table %}
      {% if perms.dcim.add_location %}
        <div class="panel-footer text-right noprint">
          <a href="{% url 'dcim:location_add' %}?site={{ object.site.pk }}&parent={{ object.pk }}" class="btn btn-xs btn-primary">
            <span class="mdi mdi-plus-thick" aria-hidden="true"></span> Add location
          </a>
        </div>
      {% endif %}
      </div>
      {% include 'inc/paginator.html' with paginator=child_locations_table.paginator page=child_locations_table.page %}
      {% plugin_full_width_page object %}
  </div>
</div>
{% endblock %}
